package com.lizx.persional.resource;


import com.baomidou.mybatisplus.plugins.Page;
import com.lizx.persional.common.utils.Result;
import com.lizx.persional.entity.Interview;
import com.lizx.persional.service.InterviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  api
 * </p>
 *
 * @author 李振兴
 * @since 2018-02-27
 */
@RestController
@RequestMapping("/persional/interview")
public class InterviewResource {
    @Autowired
    private InterviewService interviewService;

    /**
     * 面试安排列表
     * @param page
     * @param interview
     * @return
     */
    @GetMapping("/page")
    public Result page(Page<Interview> page, Interview interview){
        return Result.success(interview.selectPage(page,null));
    }

    /**
     * 新增
     * @param interview
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody Interview interview) {
        return Result.success(interview.insert());
    }

    /**
     * 根据id获取
     * @param id
     * @return
     */
    @GetMapping("/get/{id}")
    public Result getInterview(@PathVariable Long id){
        return Result.success(interviewService.selectById(id));
    }

    /**
     * 修改
     * @param interview
     * @return
     */
    @PutMapping("/update")
    public Result update(@RequestBody Interview interview){
        return Result.success(interview.updateById());
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @DeleteMapping("/delete")
    public Result delete(List<Long> ids){
        return Result.success(interviewService.deleteBatchIds(ids));
    }
}

